<template>
  <el-aside :width="iscollapse?'64px':'200px'">
     <p @click="iscollapse=!iscollapse">|||</p>

     <!-- router	是否使用 vue-router 的模式，
     启用该模式会在激活导航时以 index 作为 path 进行路由跳转	boolean	—	false
     
     collapse	是否水平折叠收起菜单（仅在 mode 为 vertical 时可用）	boolean	—	false
      -->
     <el-menu
      default-active="2"
      class="el-menu-vertical-demo"
      background-color="#545c64"
      text-color="#fff"
      router
      :collapse="iscollapse"
      active-text-color="#ffd04b">
      <!-- index	唯一标志	string/null	—	null -->
      <el-submenu 
      :index="item.id+''"
      v-for="item in menus"
      :key="item.id"
      >
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>{{item.authName}}</span>
        </template>
        <el-menu-item 
        :index="'/'+ite.path"
        v-for="ite in item.children"
        :key="ite.id"
        >
          <i class="el-icon-location"></i>
          <span>{{ite.authName}}</span>
        </el-menu-item>
       
      </el-submenu>
      
      
      
    </el-menu>
  </el-aside>
</template>

<script>
  export default {
    data() {
      return {
        menus: [],
        iscollapse:false
      }
    },
    created () {
      this.getdata();
    },
    methods: {
      getdata() {
        this.$axios.get('menus')
        .then(res=>{
          console.log(res,"zuoce")
          this.menus=res.data
        })
      }
    },
  }
</script>

<style  scoped>
p{
  height: 40px;
  line-height: 40px;
  color: #fff;
  text-align: center;
}
</style>